home *** CD-ROM | disk | FTP | other *** search
- head 1.4;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.4
- date 89.01.13.11.49.34; author douglis; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.09.15.10.16.34; author douglis; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.09.13.16.43.33; author douglis; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.08.14.15.11.35; author douglis; state Exp;
- branches ;
- next ;
-
-
- desc
- @Retrieve multiple login records from the login database.
- @
-
-
- 1.4
- log
- @tell Db_Open how many records to buffer.
- @
- text
- @/*
- * Ulog_GetAllLogins.c --
- *
- * Source code for the Ulog_GetAllLogins procedure.
- *
- * Copyright 1988 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/ulog/RCS/Ulog_GetAllLogins.c,v 1.3 88/09/15 10:16:34 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- #endif not lint
-
-
- #include <ulog.h>
- #include "ulogInt.h"
-
-
- /*
- *----------------------------------------------------------------------
- *
- * Ulog_GetAllLogins --
- *
- * Get the records for all valid login records, up to the number of
- * records specified. If the records correspond to a machine
- * that is down, they will still be returned and it is the responsibility
- * of the caller to verify the status of each machine.
- *
- * Results:
- * -1 indicates an error, in which case errno indicates more details.
- * On success, the number of structures being returned in *dataPtr
- * is returned as the value of the function.
- * *locPtr is set to the next location to be searched.
- *
- * Side effects:
- * The database file is opened for reading, locked, and later closed.
- *
- *----------------------------------------------------------------------
- */
-
- #define NUMBUF 100
-
- int
- Ulog_GetAllLogins(numEntries, locPtr, dataPtr)
- int numEntries; /* number of structures in *dataPtr */
- int *locPtr; /* index of first structure to return, set
- * to first unseen structure on return */
- Ulog_Data *dataPtr; /* Pointer to array of structures */
- {
- int status;
- Db_Handle handle;
- int i;
- register int loc = *locPtr;
- char buffer[ULOG_RECORD_LENGTH];
- Ulog_Data *thisPtr;
- int count;
-
- status = Db_Open(ULOG_FILE_NAME, ULOG_RECORD_LENGTH, &handle, 0,
- DB_LOCK_OPEN, DB_LOCK_BREAK, NUMBUF);
- if (status != 0) {
- return(status);
- }
- i = 0;
- while(i < numEntries) {
- status = Db_Get(&handle, buffer, loc);
- thisPtr = &dataPtr[i];
- /*
- * We go until we get a failure status, then return what we
- * have so far.
- */
- if (status == -1) {
- break;
- }
- count = sscanf(buffer, ULOG_FORMAT_STRING, &thisPtr->uid,
- &thisPtr->hostID, &thisPtr->portID,
- &thisPtr->updated, thisPtr->location);
- /*
- * Only return a record if its updated field is non-zero (i.e.,
- * never initialized or invalidated by being reset to 0.
- * In this case, increment i so the next record goes in the
- * next location, and increment the record number to get. If
- * sscanf can't parse the record properly, assume it's invalid.
- * It's okay if the location field doesn't match because it
- * may be empty.
- */
- if (thisPtr->updated != 0 && count >= ULOG_ITEM_COUNT - 1) {
- if (count == ULOG_ITEM_COUNT - 1) {
- thisPtr->location[0] = '\0';
- }
- i++;
- }
- loc++;
- }
- (void) Db_Close(&handle);
- *locPtr = loc;
- return(i);
- }
- @
-
-
- 1.3
- log
- @allow an empty location field (since it's last in the record, this is
- okay).
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: Ulog_GetAllLogins.c,v 1.2 88/09/13 16:43:33 douglis Exp $ SPRITE (Berkeley)";
- d47 2
- d65 1
- a65 1
- DB_LOCK_OPEN, DB_LOCK_BREAK);
- @
-
-
- 1.2
- log
- @changed to use ascii representation in database file.
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: Ulog_GetAllLogins.c,v 1.1 88/08/14 15:11:35 douglis Exp $ SPRITE (Berkeley)";
- a80 6
- if (count != ULOG_ITEM_COUNT) {
- syslog(LOG_ERR, "Ulog_GetAllLogins: unable to parse record %d",
- loc);
- errno = EACCES;
- return(-1);
- }
- d85 4
- a88 1
- * next location, and increment the record number to get.
- d90 4
- a93 1
- if (thisPtr->updated != 0) {
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d17 1
- a17 1
- static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
- d58 3
- d62 1
- a62 1
- status = Db_Open(ULOG_FILE_NAME, sizeof(Ulog_Data), &handle, 0,
- d69 2
- a70 1
- status = Db_Get(&handle, (char *) &dataPtr[i], loc);
- d78 9
- d93 1
- a93 1
- if (dataPtr[i].updated != 0) {
- @
-